<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>增加修改</title>
<link rel="stylesheet" href="../../res/layui/css/layui.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<form id="form" class="layui-form" action="../../listenStock/updateoradd.action" method="post" style="margin-top: 10px;" enctype="multipart/form-data">
		<input type="hidden" name="stockId" id="stockId"/>
		<input type="hidden" name="isva" id="isva"/ value="1">
		
	 	<div class="layui-form-item" style="width:70%;">
	      <label class="layui-form-label" >乐器名称:</label>
	      <div class="layui-input-block">
	        <select name="muId" id="muId"  color="gray" color="gray" lay-verify="required|types" >
	        <option value="">--请选择乐器--</option>
	        </select>
	      </div>
	   </div>
	   
	   <div class="layui-form-item" style="width:70%;">
	      <label class="layui-form-label" >公司名称:</label>
	      <div class="layui-input-block">
	        <select name="companyId" id="companyId"  color="gray" lay-verify="required|types" >
	        <option value="">--请选择公司--</option>
	        </select>
	      </div>
	   </div>

		<div class="layui-form-item" style="width:70%;">
	    <label class="layui-form-label">库存数量:</label>
		    <div class="layui-input-block">
		      <input name="stockNumber" lay-verify="stockNumber" maxlength="7" autocomplete="off" placeholder="请输入库存" class="layui-input" type="text" id='stockNumber'>
		    </div>
	  	</div>
	  	
	  	<div class="layui-form-item" style="width:70%;">
	    <label class="layui-form-label">批发价:</label>
		    <div class="layui-input-block">
		      <input name="wholesale" lay-verify="wholesale" autocomplete="off" placeholder="请输入批发价" class="layui-input" type="text" id='wholesale'>
		    </div>
	  	</div>
	 
	  	<br/>
	  	
	  	
	 <br/>
	  <div class="layui-form-item" style="width:70%;">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo" id="sub">立即提交</button>
	    </div>
	   </div>
</form>
<script type="text/javascript" src="../../res/layui/layui.all.js" charset="utf-8"></script>

<script type="text/javascript">
$(function(){
	jQuery.ajaxSettings.async = false;
})

layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate
	  
	  var url="../../listenMusical/MuName.action";
	  var data=null;
	  $.post(url,data,function(mes){
			$.each(mes,function(index,item){
				 $("#muId").append("<option value='"+item.muId+"'>"+item.muName+"</option>");
				 form.render();
			});
		 },"json");
	  
	  
	  var url1="../../listenCompany/queryAllzwm.action";
	  $.post(url1,data,function(mes){
		  $.each(mes,function(index,item){
			  $("#companyId").append("<option value='"+item.companyId+"'>"+item.companyName+"</option>");
				 form.render();
		  });
	  },"json");
	  
	  
	//日期
	  laydate.render({
	    elem: '#birthday'
	  });
	
	//创建一个编辑器
	  var editIndex = layedit.build('LAY_demo_editor');
	
	//自定义验证规则
	    form.verify({
	    	stockNumber: function(value){
	    		var a =/^\d*\.{0,1}\d{0,1}$/;
		      if(value.length == 0){
		        return '库存数量不能为空';
		      }else if(value.length>7){
		    	  return '最大只能支持7位数'
		      }else if(a.test($("#stockNumber").val())){
		    	 
		      }else{
		    	  return '不能输入除数字小数点以外其他字符'
		      }
	   	 	}
	   
	 	,retail: function(value){
	 		var a =/^\d*\.{0,1}\d{0,1}$/;
		      if(value.length == 0){
		        return '零售价不能为空';
		      }else if(value.length>7){
		    	  return '最大只能支持7位数'
		      }else if(a.test($("#retail").val())){
			    	 
		      }else{
		    	  return '不能输入除数字小数点以外其他字符'
		      }
		    }
	 	
	 	,wholesale: function(value){
	 		var a =/^\d*\.{0,1}\d{0,1}$/;
		      if(value.length == 0){
		        return '批售价不能为空';
		      }else if(value.length>7){
		    	  return '最大只能支持7位数'
		      }else if(a.test($("#wholesale").val())){
			    	 
		      }else{
		    	  return '不能输入除数字小数点以外其他字符'
		      }
		    }
	   
	  });  
	
	  //监听提交
	  form.on('submit(formDemo)', function(data){
		  var index=parent.layer.getFrameIndex(window.name);
		  parent.location.render();
		  parent.layer.close(index);

		  
	  });
});
function load() {
  	var form = layui.form;
  	 form.render();
}
</script>
</body>
</html>